// 通用类型定义

// 加载状态
export type LoadingState = 'idle' | 'loading' | 'success' | 'error'

// 坐标点
export interface Point2D {
    x: number
    y: number
}

export interface Point3D {
    x: number
    y: number
    z: number
}

// 边界框
export interface BoundingBox2D {
    x: number
    y: number
    width: number
    height: number
}

export interface BoundingBox3D extends BoundingBox2D {
    z: number
    depth: number
}

// 颜色定义
export interface Color {
    r: number
    g: number
    b: number
    a?: number
}

export type ColorString = string // hex, rgb, rgba等格式

// 尺寸定义
export interface Size2D {
    width: number
    height: number
}

export interface Size3D extends Size2D {
    depth: number
}

// 范围定义
export interface Range {
    min: number
    max: number
}

// 排序选项
export interface SortOption {
    field: string
    direction: 'asc' | 'desc'
}

// 过滤选项
export interface FilterOption {
    field: string
    operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'in'
    value: unknown
}

// 分页选项
export interface PaginationOption {
    page: number
    pageSize: number
    sort?: SortOption[]
    filters?: FilterOption[]
}

// 用户偏好设置
export interface UserPreferences {
    theme: 'light' | 'dark' | 'auto'
    language: 'zh-CN' | 'en-US'
    defaultViewerType: '2D' | '3D'
    autoSave: boolean
    shortcuts: Record<string, string>
}

// 应用配置
export interface AppConfig {
    apiBaseUrl: string
    maxFileSize: number
    supportedFormats: string[]
    defaultWindowLevel: {
        center: number
        width: number
    }
    performance: {
        maxConcurrentTasks: number
        cacheSize: number
        renderQuality: 'low' | 'medium' | 'high'
    }
}

// 错误类型
export interface AppError {
    code: string
    message: string
    details?: Record<string, unknown>
    timestamp: Date
    stack?: string
}

// 通知类型
export interface Notification {
    id: string
    type: 'info' | 'success' | 'warning' | 'error'
    title: string
    message: string
    duration?: number
    actions?: NotificationAction[]
    createdAt: Date
}

export interface NotificationAction {
    label: string
    action: () => void
    type?: 'primary' | 'default'
}